#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

int equal(int* s1, int* s2)
{
    int i = 0;
    while (i < 26)
    {
        if (s1[i] != s2[i])
        {
            return 0;
        }
        ++i;
    }
    return 1;
}


bool checkInclusion(char* s1, char* s2) {
    int str1[26] = { 0 };
    int str2[26] = { 0 };
    int len1 = strlen(s1);
    int len2 = strlen(s2);

    for (int i = 0; i < len1; ++i)
    {
        ++str1[s1[i] - 'a'];
    }

    int i = 0;
    while (i <= len2 - len1)
    {
        for (int j = 0; j < len1; ++j)
        {
            ++str2[s2[j + i] - 'a'];
        }

        if (equal(str1, str2))
        {
            return true;
        }
        memset(str2, 0, sizeof(str2));
        ++i;
    }
    return false;
}

int main()
{
    char str2[] = "dcda";
    char str1[] = "adc";
    if (checkInclusion(str1, str2))
    {
        printf("true\n");
    }
    else
    {
        printf("false\n");
    }
    return 0;
}